using System;
using System.Collections.Generic;
using NGUI;
using UnityEngine;
using UnityEngine.Rendering;

namespace Minesweeper.GUI.HUD.Campsite
{
    public class InteractResponser : Hidable
    {
        public InteractiveObject Target;
        
        private const string PrefabPath = "Minesweeper/Prefabs/Interact HUD";

        public static InteractResponser Create(InteractiveObject target)
        {
            var prefab = Resources.Load<GameObject>(PrefabPath); 
            InteractResponser r = Instantiate(prefab, CanvasFinder.Get("HUD").transform)
                .GetComponent<InteractResponser>();
            r.Target = target;
            r.Show();
            return r;
        }

        private void Update()
        {
            transform.anchoredPosition = Input.mousePosition;
            
            if (Input.GetKeyDown(KeyCode.E))
                Target.Interact(CampsitePlayer.Instance);
        }
    }
}
